import * as dotenv from 'dotenv';

dotenv.config({ path: '.env' });

export interface IConfig {
  port: number;
  debugLogging: boolean;
  dbsslconn: boolean;
  jwtSecret: string;
  databaseUrl: string;
  wechatAppID: string
  wechatAppSecret: string
  wechatMsgToken: string
  wechatAccessTokenPath: string
  SQLiteDatabase: string
  neDBDatabase: string
  wechatOAuthTokenPrefix: string // OAuth用户token的更新
  designFileFolder: string // 上传文件存储目录
}

const config: IConfig = {
  port: +process.env.PORT || 3000,
  debugLogging: process.env.NODE_ENV == 'development',
  dbsslconn: process.env.NODE_ENV != 'development',
  jwtSecret: process.env.JWT_SECRET || 'your-secret-whatever',
  databaseUrl: process.env.DATABASE_URL || 'postgres://user:pass@localhost:5432/apidb',
  wechatAppID: process.env.WECHAT_APPID,
  wechatAppSecret: process.env.WECHAT_APP_SECRET,
  wechatMsgToken: process.env.WECHAT_MSG_TOKEN,
  designFileFolder: process.env.DESIGN_FILE_PLACE_FOLDER || 'temp/uploads',
  wechatAccessTokenPath: './temp/wechat.accesstoken.txt',
  SQLiteDatabase: './temp/typeorm-SQLite.sqlite',
  neDBDatabase: './temp/nedb.database',
  wechatOAuthTokenPrefix: 'wechatOAuth-',
};

export { config };